home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / utilities / comms / irc / grapevine / rexx / xban.gvrexx < prev    next >
Encoding:
Text File  |  1995-07-13  |  4.9 KB  |  133 lines

  1. /*) Ban generator v1.0 for Grapevine 2.0
  2. \\\ Written by Josef Faulkner  (panther@gate.net) IRC: Arexx
  3. ///     
  4. \\\ Features:
  5. /// ~~~~~~~~~
  6. \\\ - Supports IP addresses as well as names
  7. /// - bans hostname by last two parts
  8. \\\ - Removes ~ and ^ characters from userid
  9. ///
  10. \\\ Format:
  11. /// ~~~~~~~
  12. \\\ This program converts as following:
  13. ///
  14. \\\ user@host.dom                         --> *!*user@*host.dom
  15. /// ^user@my.really.long.name.host.dom    --> *!*user@*host.dom
  16. \\\ ~user@127.0.0.1                       --> *!*user@127.0.0.*
  17. ///
  18. \\\ Installation:
  19. /// ~~~~~~~~~~~~~
  20. \\\ ASSIGN GV: to wherever you store your arexx programs!
  21. ///
  22. \\\ /alias xban rx xban.gv
  23. ///
  24. \\\ or add to your startup.gv:
  25. /// alias xban 'rx xban.gv'
  26. \\\
  27. /// Usage:      
  28. \\\ ~~~~~~
  29. /// /xban <nick>   - Bans <nick>
  30. \\\ /xban -<nick>  - Unbans <nick>
  31. ///
  32. \\\ Special Notes:
  33. /// ~~~~~~~~~~~~~~
  34. \\\ HACK ALERT - Be Careful!
  35. ///
  36. \\\ This is the first program I am distributing that uses the "scan log"
  37. /// feature to get results back from grapevine.  Some precautions must be
  38. \\\ taken for this to work, or to prevent from banning the wrong person:
  39. ///
  40. \\\ 1. DO NOT use the /who command between the time you issue the /xban command
  41. /// and the ban is actually put into place.  This could result in the person you
  42. \\\ do a /who on, getting banned instead.
  43. /// 
  44. \\\ 2. You cannot use logs, if you have a log running, it will be stopped when
  45. /// this program is executed
  46. \\\
  47. /// 3. You must have GV: assigned, if it isnt assigned I dont know what will
  48. \\\ happen :)
  49. ///
  50. \\\ Technical Notes:
  51. /// ~~~~~~~~~~~~~~~~
  52. \\\ This program calls itself again, because the logs cant be used on scripts
  53. /// directly called from GV.  If you find your server is slow, increase the
  54. \\\ delay() value.  If you find that the bans take too long, and the who
  55. /// info returns fairly quickly, decrease it.
  56. \\\
  57. (*/
  58.  
  59. options results
  60. parse arg nick addr
  61. if ~show('L','rexxsupport.library') then if ~addlib('rexxsupport.library',0,-30,0) then do
  62.         'echo You need rexxsupport.library version 30 or greater in libs:'
  63.         exit 10 
  64. end
  65. nick=strip(nick)
  66. if left(nick,1)='-' then do
  67.         nick=right(nick,length(nick)-1)
  68.         unban=1
  69. end
  70. else unban=0
  71. addr=strip(addr)
  72. if addr='' then do
  73.         parse source . . thisscript .
  74.         thissscript=strip(thisscript)
  75.         address command 'run rx 'thisscript' 'nick' 'address()
  76. end
  77. else do
  78.         interpret 'address 'addr
  79.         call delete('T:ban')
  80.         'closelog'
  81.         'log t:ban'
  82.         'who 'nick
  83.         call delay(150)
  84.         'closelog'
  85.         call open(1,'t:ban',r)
  86.         done=0
  87.         do until (eof(1))|(done)
  88.                 text=readln(1)
  89.                 if word(text,1)='«Who»' then do
  90.                         if upper(word(text,4))=upper(nick) then do
  91.                                 banid=word(text,6)
  92.                                 banid=strip(banid,'B','~')
  93.                                 banid=strip(banid,'B','^')
  94.                                 dots=0
  95.                                 dotpos=1
  96.                                 do until index(banid,'.',dotpos)=0
  97.                                         dotpos=index(banid,'.',dotpos)+1
  98.                                         dots=dots+1
  99.                                 end
  100.                                 host=left(reverse(banid),(index(reverse(banid),'@')-1))
  101.                                 num=0
  102.                                 if dots>1 then do                                       
  103.                                         if datatype(left(host,index(host,'.')),n)&(dots=3) then do
  104.                                                 bannum=reverse(right(host,length(host)-(index(host,'.'))))
  105.                                                 num=1
  106.                                         end
  107.                                         banhost=left(host,index(host,'.'))
  108.                                         host=right(host,length(host)-length(banhost))
  109.                                         banhost=banhost||left(host,index(host,'.')-1)
  110.                                         banhost=reverse(banhost)
  111.                                         if num then do
  112.                                                 banhost=bannum
  113.                                         end
  114.                                 end
  115.                                 else banhost=reverse(host)
  116.                                 if num then do
  117.                                         banid='*!*'left(banid,index(banid,'@'))||banhost||'.*'
  118.                                 end
  119.                                 else do
  120.                                         banid='*!*'left(banid,index(banid,'@'))||'*'||banhost
  121.                                 end
  122.                                 if unban then 'unban 'banid
  123.                                 else 'ban 'banid
  124.                                 done=1
  125.                         end
  126.                 end
  127.         end
  128.         call close(1)
  129.         if done=0 then 'echo 'nick' not on IRC.'
  130.         call delete('t:ban')
  131. end
  132. exit
  133.